#ifndef _AGORA_LOGIC_H
#define _AGORA_LOGIC_H

#if defined(_WIN32) || defined(_WIN64)
	#include <Windows.h>
#else
	#include <unistd.h>
	#include <stdlib.h>
	#include <string.h>
#endif

#include <math.h>
#include <stdio.h>
#include <dirent.h>

#include "utils.h"
#include "globals.h"

class Logic{
private:
	agr_user *user;
	std::vector<agr_user*> userList;

	u64 fileHandler;

	#pragma pack(push, 1)
	struct chunk_s{
		u8 status;
		u64 offset;
		u64 size;
	};
	#pragma pack(pop, 1)

public:
	Logic(agr_user *user);

	static Logic *initializeLogic(agr_user *user){
		strcpy(user->username, "test");

		if(!agr_utils::getIP(user->ip))
		  return NULL;

		Logic *logic = new Logic(user);
		return logic;
	};

	void addUser(agr_user *user);

	std::vector<agr_user*> getUserList();
	agr_user *getUser();
	void removeUser(agr_user *user);

	agr_file *createFile(char *path);
	agr_file *openFile(char *path);
	bool fileInflate(agr_file *file, u64 size);
	bool readFileChunks(agr_file *file);
	bool detectFiles();
};

#endif